package com.jzo2o.market.controller;

import com.jzo2o.common.model.PageResult;
import com.jzo2o.market.model.dto.request.ActivityQueryForPageReqDTO;
import com.jzo2o.market.model.dto.request.ActivitySaveReqDTO;
import com.jzo2o.market.model.dto.response.ActivityInfoResDTO;
import com.jzo2o.market.service.IActivityService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Description ActivityController
 * @Author luohai
 * @Date 2024-12-15
 */
@RestController("OperationController")
@RequestMapping("/operation/activity")
@Api(tags = "运营端-优惠券相关接口")
public class ActivityController {

    @Autowired
    private IActivityService activityService;
    /**
     * 保存优惠券活动
     * @param activitySaveReqDTO
     */
    @PostMapping("/save")
    @ApiOperation("保存优惠券活动")
    public void saveActivity(@RequestBody ActivitySaveReqDTO activitySaveReqDTO){
        activityService.saveActivity(activitySaveReqDTO);
    }

    /**
     * 分页查询优惠券活动
     * @param dto
     * @return
     */
    @GetMapping("/page")
    @ApiOperation("分页查询优惠券活动")
    public PageResult<ActivityInfoResDTO> getActivityList(ActivityQueryForPageReqDTO dto){
        return activityService.getActivityList(dto);
    }

    /**
     * 查询优惠券活动详情
     * @param id
     * @return
     */
    @GetMapping("/{id}")
    @ApiOperation("查询优惠券活动详情")
    public ActivityInfoResDTO searchActivityById(@PathVariable Long id){
        return activityService.searchActivityById(id);
    }

    /**
     * 撤销活动接口
     * @param id
     */
    @PostMapping("/revoke/{id}")
    @ApiOperation("撤销活动接口")
    public void revoke(@PathVariable Long id){
        activityService.revoke(id);
    }

}
